﻿using BCCommon;
using BCCommon.Enums;
using BCDto.WeChatComponent.WeChatMessageRecord;
using BCService.WeChatComponent.WeChatMessageRecordService;
using Microsoft.AspNetCore.Mvc;
using System;

namespace BCTMSRESTful.Controllers.Management.WeChat
{
    /// <summary>
    /// 微信自定义菜单控制器
    /// </summary>
    [ApiExplorerSettings(GroupName = "Admin")]
    [Route("api/v1/sim/[controller]")]
    public class WeChatMessageController : ManagementBaseController
    {
        private readonly IWeChatMessageRecordService weChatMessageRecordService;

        public WeChatMessageController(IWeChatMessageRecordService weChatMessageRecordService)
        {
            this.weChatMessageRecordService = weChatMessageRecordService;
        }

        /// <summary>
        /// 获取微信自定义菜单列表。
        /// </summary>
        /// <response code="200">获取微信自定义菜单列表。</response>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<WeChatMessageRecordDto>), 200)]
        public IActionResult Query([FromQuery(Name = "from_user_openid")]string fromUserOpenId,
            [FromQuery(Name = "to_user_openid")]string toUserOpenId,
            [FromQuery(Name = "msg_type")]WeChatMessageType? msgType,
            [FromQuery(Name = "start")]DateTime? start,
            [FromQuery(Name = "end")]DateTime? end,
            [FromQuery(Name = "is_replied")]bool? isReplied, 
            [FromQuery(Name = "ascending")]bool? ascending,
            [FromQuery(Name = "index")]int index = 1,
            [FromQuery(Name = "size")]int size = 10)
        {
            return this.Ok(this.weChatMessageRecordService.Get(fromUserOpenId,toUserOpenId,start,end, msgType,isReplied,null,null,ascending,index,size));
        }
    }
}
